package com.atzexu.service.impl;

import com.atzexu.domain.dto.AddIntegratingDTO;
import com.atzexu.domain.User;
import com.atzexu.mapper.UserMapper;
import com.atzexu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * user表业务层实现类
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    /**
     * 通过mobile查询用户类型
     *
     * @param mobile
     * @return
     */
    @Override
    public User getUserTypeByMobile(String mobile) {
        return userMapper.getUserTypeByMobile(mobile);
    }

    /**
     * 通过账号和密码查询User
     *
     * @return
     */
    @Override
    public User getUserByUserNameAndPassword(User user) {
        return userMapper.getUserByUserNameAndPassword(user);
    }

    /**
     * 通过班级id查询所有学生
     *
     * @param classId
     * @return
     */
    @Override
    public List<User> findByClassId(Integer classId) {
        return userMapper.findByClassId(classId);
    }

    /**
     * 添加用户积分
     *
     * @param user
     * @return
     */
    @Override
    public boolean addIntegral(AddIntegratingDTO user) {
        int i = userMapper.addIntegral(user);
        return i > 0;
    }

    /**
     * 重置小组积分
     *
     * @param classId
     * @return
     */
    @Override
    public boolean resetGScoreByGroupId(Integer classId) {
        int i = userMapper.resetGScoreByGroupId(classId);
        return i > 0;
    }
}
